package cn.school.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import cn.school.dao.StudentDao;
import cn.school.entity.Student;
import cn.school.util.BatisUtil;

public class StudentService {
	public List<Student> findALL() throws Exception {
		SqlSession s = BatisUtil.createSqlSession();
		try {
			StudentDao st = s.getMapper(StudentDao.class);
			return st.findALL();
		} finally {
			BatisUtil.closeSqlSession(s);
		}
	}

	public int add(Student s) throws Exception {
		SqlSession s1 = BatisUtil.createSqlSession();
		try {
			StudentDao st = s1.getMapper(StudentDao.class);
			return st.add(s);
		} finally {
			BatisUtil.closeSqlSession(s1);
		}
	}
}
